package com.ruoyi.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.TDialysisRecord;
import com.ruoyi.business.service.ITDialysisRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 腹膜透析记录Controller
 * 
 * @author ruoyi
 * @date 2025-03-12
 */
@RestController
@RequestMapping("/business/dlrecord")
public class TDialysisRecordController extends BaseController
{
    @Autowired
    private ITDialysisRecordService tDialysisRecordService;

    /**
     * 查询腹膜透析记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:dlrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(TDialysisRecord tDialysisRecord)
    {
        startPage();
        List<TDialysisRecord> list = tDialysisRecordService.selectTDialysisRecordList(tDialysisRecord);
        return getDataTable(list);
    }

    /**
     * 导出腹膜透析记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:dlrecord:export')")
    @Log(title = "腹膜透析记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TDialysisRecord tDialysisRecord)
    {
        List<TDialysisRecord> list = tDialysisRecordService.selectTDialysisRecordList(tDialysisRecord);
        ExcelUtil<TDialysisRecord> util = new ExcelUtil<TDialysisRecord>(TDialysisRecord.class);
        util.exportExcel(response, list, "腹膜透析记录数据");
    }

    /**
     * 获取腹膜透析记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:dlrecord:query')")
    @GetMapping(value = "/{status}")
    public AjaxResult getInfo(@PathVariable("status") String status)
    {
        return success(tDialysisRecordService.selectTDialysisRecordByStatus(status));
    }

    /**
     * 新增腹膜透析记录
     */
    @PreAuthorize("@ss.hasPermi('business:dlrecord:add')")
    @Log(title = "腹膜透析记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TDialysisRecord tDialysisRecord)
    {
        return toAjax(tDialysisRecordService.insertTDialysisRecord(tDialysisRecord));
    }

    /**
     * 修改腹膜透析记录
     */
    @PreAuthorize("@ss.hasPermi('business:dlrecord:edit')")
    @Log(title = "腹膜透析记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TDialysisRecord tDialysisRecord)
    {
        return toAjax(tDialysisRecordService.updateTDialysisRecord(tDialysisRecord));
    }

    /**
     * 删除腹膜透析记录
     */
    @PreAuthorize("@ss.hasPermi('business:dlrecord:remove')")
    @Log(title = "腹膜透析记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{statuss}")
    public AjaxResult remove(@PathVariable String[] statuss)
    {
        return toAjax(tDialysisRecordService.deleteTDialysisRecordByStatuss(statuss));
    }
}
